﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.ComponentModel;

namespace UIPrototyper
{
    class ButtonProperties : Property, IChanged
    {
        private CustomButton button;

        private string screen, screenID;

        public ButtonProperties(CustomButton pButton)
        {
            this.button = pButton;
        }

        [Browsable(false)]
        public string ScreenID
        {
            get
            {
                if (screen != null)
                    screenID = screen.Split('{')[screen.Split('{').Length - 1].Replace("}", "");

                if (screenID == null)
                    screenID = "";

                return screenID;
            }

            set { screenID = value; }
        }

        [DescriptionAttribute("O nome do botão"),
        CategoryAttribute("Button")]
        public override string Nome
        {
            get { return this.button.Name; }
            set { this.button.Name = value; LaunchChangedEvent(this.button); }
        }

        [DescriptionAttribute("O texto do botão"),
        CategoryAttribute("Button")]
        public string Texto
        {
            get { return this.button.Content.ToString(); }
            set { this.button.Content = value; LaunchChangedEvent(this.button); }
        }

        [TypeConverter(typeof(ScreenConverter)),
        DescriptionAttribute("A Tela para onde o botão aponta quando clicado"),
        CategoryAttribute("Button")]
        public string Tela
        {
            get { return screen; }
            set { screen = value; LaunchChangedEvent(this.button); }
        }

        #region IChanged Members

        public event ChangedHandler iChanged;

        public void LaunchChangedEvent(IChanged pChangedObject)
        {
            if (iChanged != null)
            {
                iChanged(pChangedObject);
            }
        }

        #endregion
    }
}
